

<script>

$(function(){

				
				$('.server_user').editable({
					ajaxOptions:{dataType:'json'},
					source: <?php echo $server_user;?>,
					success:function(response, newValue){
						if(response.error==1){
							alert(response.msg);
							window.location.reload();
						 }
						
					}
				});
				
				
				$('.gasstation').editable({	
									source: <?php echo $gasstation;?>
				});
				
				$('.status').editable({	
									source: <?php echo $status;?>
				});
				
				$('.car_type').editable({	
									source: <?php echo $car_type;?>
				});
				
				
				$('.followup').poshytip({
					className: 'tip-yellowsimple',
					content: function(updateCallback) {
						var f_id=$(this).attr('f_id')
						
						$.ajax({
						   type: "POST",
						   url: "<?php echo base_url().'crm/user/get_follow_up'?>",
						   data: "id="+f_id,
						   success: function(msg){
							 updateCallback(msg);
						   }
						});
					
						
						return 'Loading...';
					}
				});
				
				
})

function import_excel(){
	art.dialog({
	title:'导入',
    content: document.getElementById('import_form'),
    id: 'EF893L'
});

	
}


function export_excel(){
	$('#export').val(1);
	$('#list_form').submit();
	
	
	}	
</script>


<div class="main-content">

	<form id="import_form" method="post"  action="<?php echo base_url().'crm/user/import_excel'?>" style="display:none;" enctype='multipart/form-data'>
    	<input type="file"  style="float:left;"  name="file"/>
        <button class="btn btn-info btn-sm" type="submit">提交</button>
    
    </form>
	<div class="breadcrumbs" id="breadcrumbs">
		<script type="text/javascript">
			try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
		</script>

		<!-- .breadcrumb -->
	</div>

	<div class="page-content">
		<div class="row">
			<div class="page-header">
				<h1>潜在客户列表</h1>
			</div>
            <div class="col-xs-12">
			
        
	        </div>
	        <div class="col-md-12 col-sm-12 col-xs-12 form">
	        <?php if($_SESSION['user_name'] == 'dingdangcrm'):?>
	        <div>
	        	<p>发起邀请总人数：<?php echo $user_invite->from_user_id?></p>
	        	<p>被邀请总人数：<?php echo $user_invite->user?></p>
	        </div>
	    	<?php endif?>
			<div style="margin-bottom:25px; text-align:right;">
            <a class="a_btn a_right" href="<?php echo base_url().'crm/user/add_potential'?>"><i class="icon-copy"></i>新增</a>
            <a class="a_btn a_right" href="javascript:import_excel()"><i class="icon-copy"></i>导入</a>
            <?php if($_SESSION['user_name'] == 'dingdangcrm'):?><a class="a_btn a_right" href="javascript:export_excel()"><i class="icon-copy"></i>导出</a><?php endif?>
            
            <a class="a_btn a_right" href="javascript:$('#col_ul').toggle()"><i class="icon-copy"></i>编辑列</a>
            
            
            <ul id="col_ul" style="display:none;">
            	<li onclick="col_show('mobile')">手机 <?php if(!empty($col_array['mobile'])):?><img src="<?php echo site_url();?>themes/default/images/jia_m.jpg" /><?php else:?> <img src="<?php echo site_url();?>themes/default/images/jian_m.jpg" /><?php endif;?></li>
                <li onclick="col_show('gasstation')">加油站 <?php if(!empty($col_array['gasstation'])):?><img src="<?php echo site_url();?>themes/default/images/jia_m.jpg" /><?php else:?> <img src="<?php echo site_url();?>themes/default/images/jian_m.jpg" /><?php endif;?></li>
                <li onclick="col_show('status')">客户状态 <?php if(!empty($col_array['status'])):?><img src="<?php echo site_url();?>themes/default/images/jia_m.jpg" /><?php else:?> <img src="<?php echo site_url();?>themes/default/images/jian_m.jpg" /><?php endif;?></li>
                <li onclick="col_show('third')">客户来源 <?php if(!empty($col_array['third'])):?><img src="<?php echo site_url();?>themes/default/images/jia_m.jpg" /><?php else:?> <img src="<?php echo site_url();?>themes/default/images/jian_m.jpg" /><?php endif;?></li>
                <li onclick="col_show('car_type')">客户性质 <?php if(!empty($col_array['car_type'])):?><img src="<?php echo site_url();?>themes/default/images/jia_m.jpg" /><?php else:?> <img src="<?php echo site_url();?>themes/default/images/jian_m.jpg" /><?php endif;?></li>
                <li onclick="col_show('order_count')">订单数量 <?php if(!empty($col_array['order_count'])):?><img src="<?php echo site_url();?>themes/default/images/jia_m.jpg" /><?php else:?> <img src="<?php echo site_url();?>themes/default/images/jian_m.jpg" /><?php endif;?></li>
                <li onclick="col_show('server_user')">负责人 <?php if(!empty($col_array['server_user'])):?><img src="<?php echo site_url();?>themes/default/images/jia_m.jpg" /><?php else:?> <img src="<?php echo site_url();?>themes/default/images/jian_m.jpg" /><?php endif;?></li>
                <li onclick="col_show('has_weixin')">加微信 <?php if(!empty($col_array['has_weixin'])):?><img src="<?php echo site_url();?>themes/default/images/jia_m.jpg" /><?php else:?> <img src="<?php echo site_url();?>themes/default/images/jian_m.jpg" /><?php endif;?></li>
                <li onclick="col_show('has_group')">入群 <?php if(!empty($col_array['has_group'])):?><img src="<?php echo site_url();?>themes/default/images/jia_m.jpg" /><?php else:?> <img src="<?php echo site_url();?>themes/default/images/jian_m.jpg" /><?php endif;?></li>
                <li onclick="col_show('new_follow')">最近跟进 <?php if(!empty($col_array['new_follow'])):?><img src="<?php echo site_url();?>themes/default/images/jia_m.jpg" /><?php else:?> <img src="<?php echo site_url();?>themes/default/images/jian_m.jpg" /><?php endif;?></li>
                <li onclick="col_show('latest_time')">跟进时间 <?php if(!empty($col_array['latest_time'])):?><img src="<?php echo site_url();?>themes/default/images/jia_m.jpg" /><?php else:?> <img src="<?php echo site_url();?>themes/default/images/jian_m.jpg" /><?php endif;?></li>
            </ul>
            <script>
            	function col_show(col_str){
						$.ajax({
							type: "POST",
						    url: "<?php echo site_url();?>crm/user/col_show",
						    data: "col_str="+col_str,
						    success: function(msg){
							 	window.location.reload();
						    }
						});
					
					}
            
            </script>
            <style>
				#col_ul{
					border:1px solid #ddd;
					position:absolute;
					z-index:99;
					right:0px;
					background-color:#FFF;
					
					width:100px;
					}
            	#col_ul li{
					padding:5px;
					
					border-bottom:1px solid #ddd;
					
				 }
				 #col_ul li:hover{
					 cursor: pointer;
					 }
				 th{
					 white-space: nowrap;
					 }	 
            </style>
            
            </div>
        	<div class="col-xs-12 margin_t margin_b" style=" border:2px solid #dde0e7; padding:10px;">
				<div class="table-responsive  tab" style="width:100%; overflow-x: scroll;">
				<form action="<?php echo site_url()?>crm/user/potential" method="get" id="list_form" >
                <input type="hidden" value="0" id="export" name="export" />
					<table id="sample-table-1" class="table table-striped table-bordered table-hover" style="width:1300px;">
						<thead>
							<tr>
								
								<th>全选</th>
                                <th  <?php if(!empty($col_array['mobile'])):?>style="display:none;"<?php endif;?>width="50">手机</th>
								<th <?php if(!empty($col_array['gasstation'])):?>style="display:none;"<?php endif;?>width="50">加油站</th>
                                <th <?php if(!empty($col_array['status'])):?>style="display:none;"<?php endif;?> width="50">客户状态</th>
                                <th >邀请人数</th>
                                <th >邀请人电话</th>
                                <th <?php if(!empty($col_array['city_id'])):?>style="display:none;"<?php endif;?> width="50">城市</th>
                                <th <?php if(!empty($col_array['third'])):?>style="display:none;"<?php endif;?> width="50">客户来源</th>
                                <th <?php if(!empty($col_array['car_type'])):?>style="display:none;"<?php endif;?> width="50">客户性质</th>
                                <th <?php if(!empty($col_array['order_count'])):?>style="display:none;"<?php endif;?> width="50">订单数量</th>
								<th <?php if(!empty($col_array['server_user'])):?>style="display:none;"<?php endif;?> width="50">负责人</th>
								<th <?php if(!empty($col_array['has_weixin'])):?>style="display:none;"<?php endif;?> style="text-align:center;"width="50">加微信</th>
								<th <?php if(!empty($col_array['has_group'])):?>style="display:none;"<?php endif;?> style="text-align:center;"width="50">入群</th>
                                <th <?php if(!empty($col_array['new_follow'])):?>style="display:none;"<?php endif;?>>最近跟进</th>
								<th <?php if(!empty($col_array['latest_time'])):?>style="display:none;"<?php endif;?>>跟进时间</th>
                                <th>注册时间</th>
                                <th>操作</th>
							</tr>
                            
						</thead>

						<tbody>
                         
                        	<tr>
								
								<td  align="center"><input type="checkbox" id="select_all" /></td>
                                <td <?php if(!empty($col_array['mobile'])):?>style="display:none;"<?php endif;?> ><input type="text" name="phone"  style="width:80px;" placeholder="搜索手机号" value="<?php echo !empty($_GET['phone'])?$_GET['phone']:''?>"/></td>
								<td <?php if(!empty($col_array['gasstation'])):?>style="display:none;"<?php endif;?>><select style="width:80px;" name="gid">
                                	<option value="">请选择</option>
                                	 <?php foreach($gas_array as $v):?>
                                    <option value="<?php echo $v['value']?>" <?php if(!empty($_GET['gid'])&&$_GET['gid']==$v['value']):?>selected="selected"<?php endif;?>><?php echo $v['text']?></option>
                                    <?php endforeach;?>
                                </select></td>
                                <td <?php if(!empty($col_array['status'])):?>style="display:none;"<?php endif;?>>
                                	<select name="status">
	                                    <option value="" >请选择</option>
	                                    
	                                    <option value="1" <?php if(!empty($_GET['status'])&&$_GET['status']==1):?>selected="selected"<?php endif;?> >已转化客户</option>
	                                    <option value="2"  <?php if(!empty($_GET['status'])&&$_GET['status']==2):?>selected="selected"<?php endif;?>>注册用户</option>
	                                    <option value="3"  <?php if(!empty($_GET['status'])&&$_GET['status']==3):?>selected="selected"<?php endif;?>>成交客户</option>
	                                    <option value="4"  <?php if(!empty($_GET['status'])&&$_GET['status']==4):?>selected="selected"<?php endif;?>>流失客户</option>
	                                    
	                                    <option value="5"  <?php if(!empty($_GET['status'])&&$_GET['status']==5):?>selected="selected"<?php endif;?>>潜在客户</option>
	                                    <option value="6" <?php if(!empty($_GET['status'])&&$_GET['status']==6):?>selected="selected"<?php endif;?>>无效客户</option>
	                                    <option value="7" <?php if(!empty($_GET['status'])&&$_GET['status']==7):?>selected="selected"<?php endif;?>>未注册</option>
	                                </select>
                                </td>
                                <td>
                                </td>
                                <td>
                                	邀请人手机号
                                </td>
                                <td>
                                	<select name="city">
	                                    <option value="" >请选择</option>
	                                    <?php foreach($city as $row):?>
	                                    	<option value="<?php echo $row['id']?>" <?php if(!empty($_GET['city'])&&$_GET['city']==$row['id']):?>selected="selected"<?php endif;?> ><?php echo $row['name']?></option>
	                                	<?php endforeach?>
	                                </select>
                                </td>
                                <td <?php if(!empty($col_array['third'])):?>style="display:none;"<?php endif;?>>
                                	<select name="third">
                                     <option value="">请选择</option>
                                     <option value="-1" <?php if(isset($_GET['third'])&&$_GET['third']=='-1'):?>selected="selected"<?php endif;?>>好友邀请</option>
                                     <option value="0" <?php if(isset($_GET['third'])&&$_GET['third']=='0'):?>selected="selected"<?php endif;?>>钉铛</option>
                                	<?php foreach($third as $v):?>
                                    <option value="<?php echo $v['id']?>" <?php if(!empty($_GET['third'])&&$_GET['third']==$v['id']):?>selected="selected"<?php endif;?>><?php echo $v['name']?></option>
                                    <?php endforeach;?>
                                </select>
                                </td>
                                <td <?php if(!empty($col_array['car_type'])):?>style="display:none;"<?php endif;?>>
                                	<select name="car_type">
                                    <option value="">请选择</option>
                                	<option value="1" <?php if(!empty($_GET['car_type'])&&$_GET['car_type']==1):?>selected="selected"<?php endif;?>>网约车</option>
                                    <option value="0" <?php if(isset($_GET['car_type'])&&$_GET['car_type']=='0'):?>selected="selected"<?php endif;?>>私家车</option>
                                </select>
                                </td>
                                <td <?php if(!empty($col_array['order_count'])):?>style="display:none;"<?php endif;?>><input  type="text" name="order_count" style="width:60px;" value="<?php echo !empty($_GET['order_count'])?$_GET['order_count']:''?>"/></td>
								<td <?php if(!empty($col_array['server_user'])):?>style="display:none;"<?php endif;?>>
                                <select name="server_user">
                                	<option value="">请选择</option>
                                    <option value="0" <?php if(isset($_GET['server_user'])&&$_GET['server_user']=='0'):?>selected="selected"<?php endif;?>>未分配</option>
                                	<?php foreach($server_userlist as $v):?>
                                    <option value="<?php echo $v['id']?>" <?php if(!empty($_GET['server_user'])&&$_GET['server_user']==$v['id']):?>selected="selected"<?php endif;?>><?php echo $v['real_name']?></option>
                                    <?php endforeach;?>
                                </select>
                                </td>
								<td <?php if(!empty($col_array['has_weixin'])):?>style="display:none;"<?php endif;?>>
                                <select name="has_weixin">
                                	<option value="">请选择</option>
                                	<option value="1" <?php if(!empty($_GET['has_weixin'])&&$_GET['has_weixin']==1):?>selected="selected"<?php endif;?>>是</option>
                                    <option value="0" <?php if(isset($_GET['has_weixin'])&&$_GET['has_weixin']=='0'):?>selected="selected"<?php endif;?>>否</option>
                                </select></td>
								<td <?php if(!empty($col_array['has_group'])):?>style="display:none;"<?php endif;?>>
                                <select name="has_group">
                                	<option value="">请选择</option>
                                	<option value="1"<?php if(!empty($_GET['has_group'])&&$_GET['has_group']==1):?>selected="selected"<?php endif;?>>是</option>
                                    <option value="0" <?php if(isset($_GET['has_group'])&&$_GET['has_group']=='0'):?>selected="selected"<?php endif;?>>否</option>
                                </select>
                                </td>
                                <td <?php if(!empty($col_array['new_follow'])):?>style="display:none;"<?php endif;?>></td>
								<td <?php if(!empty($col_array['latest_time'])):?>style="display:none;"<?php endif;?>><input style="width:50px; display:inline;"  value="<?php echo !empty($_GET['follow_start'])?$_GET['follow_start']:'';?>" id="follow_start" name="follow_start" />到<input style="width:50px; display:inline;" value="<?php echo !empty($_GET['follow_end'])?$_GET['follow_end']:'';?>" id="follow_end" name="follow_end" /></td>
                                <td><input style="width:50px; display:inline;"   id="reg_start" name="register_start"  value="<?php echo !empty($_GET['register_start'])?$_GET['register_start']:'';?>"/>到<input id="reg_end" name="register_end" style="width:50px; display:inline;" value="<?php echo !empty($_GET['register_end'])?$_GET['register_end']:'';?>" /></td>
                                <td><p><button type="submit" onclick="javascript:$('#export').val(0);$('#list_form').submit();" class="btn btn-info btn-sm " href="" ><i class="icon-copy"></i>搜索</button></p></td>
                               
							</tr>
                        
							<?php if (isset($result)&&count($result)>0){
                            	foreach ($result as $app){
                            	?>
							<tr>
								
								<td align="center"><input type="checkbox" name="ids[]" class="ids" value="<?php echo $app->id;?>" /></td>
								<td <?php if(!empty($col_array['mobile'])):?>style="display:none;"<?php endif;?>><p><?php  echo $app->phone?></p></td>
								<td <?php if(!empty($col_array['gasstation'])):?>style="display:none;"<?php endif;?>>
									<p>
									<a href="###"   data-type="select" data-url="<?php echo base_url().'crm/user/edit_potential_gasstation'?>" data-pk="<?php echo $app->id?>" data-title="选择加油站" data-value="<?php echo $app->gas_name;?>" class="editable editable-click gasstation"><?php if(empty($app->gas_name)){echo '未分配';}else{echo $app->gas_name;}?></a>
									</p>
								
								</td>
								
								<td <?php if(!empty($col_array['status'])):?>style="display:none;"<?php endif;?>>
                                <p>
                                <a href="###"   data-type="select" data-url="<?php echo base_url().'crm/user/edit_potential_status'?>" data-pk="<?php echo $app->id?>" data-title="客户状态" data-value="<?php echo $app->status_str;?>" class="editable editable-click status"><?php echo $app->status_str;?></a>
								
                                </p></td>
                                <td>
                                	<?php echo isset($app->lower)?$app->lower : 0 ?>
                                </td>
                                <td>
                                	<?php echo isset($app->from_user_mobile)?$app->from_user_mobile : 0 ?>
                                </td>
                                <td><?php foreach($city as $row):?><?php if($row['id'] == $app->city_id):?> <?php echo $row['name']?><?php endif?><?php endforeach?></td>
                                <td <?php if(!empty($col_array['third'])):?>style="display:none;"<?php endif;?>><p><?php  if(!empty($app->third_id)){echo $third[$app->third_id]['name'];}?></p></td>
                                <td <?php if(!empty($col_array['car_type'])):?>style="display:none;"<?php endif;?>>
                                <p>
                                <a href="###"   data-type="select" data-url="<?php echo base_url().'crm/user/edit_potential_car_type'?>" data-pk="<?php echo $app->id?>" data-title="客户性质" data-value="<?php echo $app->car_type;?>" class="editable editable-click car_type"><?php  if(empty($app->car_type)){echo '私家车';}else{echo '网约车';}?></a>
								
                                </p>
                                </td>
                                <td <?php if(!empty($col_array['order_count'])):?>style="display:none;"<?php endif;?>><p><?php  echo $app->order_count?></p></td>
								<td <?php if(!empty($col_array['server_user'])):?>style="display:none;"<?php endif;?>>
									<p>
									<a href="###"   data-type="select" data-url="<?php echo base_url().'crm/user/potential_server_user'?>" data-pk="<?php echo $app->id?>" data-title="选择负责人" data-value="<?php echo $app->server_user;?>" class="editable editable-click server_user"><?php if(empty($app->server_user)){echo '未分配';}else{echo $app->server_user;}?></a>
									</p>
								</td>
								
								
								<td <?php if(!empty($col_array['has_weixin'])):?>style="display:none;"<?php endif;?> align="center"><p><?php  if($app->has_weixin):?><a href="<?php echo base_url()."crm/user/cancle_weixin/".$app->id?>"><img src="<?php echo base_url()."themes/default/images/access_allow.gif"?>" /></a><?php else:?><a href="<?php echo base_url()."crm/user/added_weixin/".$app->id?>"><img src="<?php echo base_url()."themes/default/images/access_disallow.gif"?>" /></a><?php endif;?></p></td>
								
								
								<td <?php if(!empty($col_array['has_group'])):?>style="display:none;"<?php endif;?> align="center"><p><?php  if($app->has_group):?><a href="<?php echo base_url()."crm/user/cancle_group/".$app->id?>"><img src="<?php echo base_url()."themes/default/images/access_allow.gif"?>" /></a><?php else:?><a href="<?php echo base_url()."crm/user/added_group/".$app->id?>"><img src="<?php echo base_url()."themes/default/images/access_disallow.gif"?>" /></a><?php endif;?></p></td>
								
								
								<td <?php if(!empty($col_array['new_follow'])):?>style="display:none;"<?php endif;?>><p><?php  echo $app->new_follow;?></p></td>
								<td <?php if(!empty($col_array['latest_time'])):?>style="display:none;"<?php endif;?>><p><?php  echo $app->latest_time!='0000-00-00 00:00:00'?date('Y-m-d',strtotime($app->latest_time)):'';?></p></td>
								<td><p><?php  echo $app->reg_time!='0000-00-00 00:00:00'?date('Y-m-d',strtotime($app->reg_time)):'';?></p></td>
								
								<td><p><a class="btn btn-info btn-sm " href="javascript:follow(<?php echo $app->id?>)" ><i class="icon-copy"></i>跟进</a></p></td>
                               
    						</tr>
    						<?php }
                            }else{?>
                            <tr>
                            	<td colspan="15">无数据</td>
                            </tr>
                            <?php }?>
						</tbody>
					</table>
					</form>
				</div><!-- /.table-responsive -->
				
                
            
            </div>
        	
        	<div class="col-sm-12">
            	<div class="modal-footer no-margin-top">
                	<div style="float:left; padding-top:3px;">
						已选择 <span id="select_num">0</span>条 | &nbsp;&nbsp;<a href="javascript:edit_user()" class="a_btn">编辑</a> &nbsp;<a href="javascript:remove_user()" class="a_btn">移交</a> <!--&nbsp;<a href="javascript:send_msg()" class="a_btn">发送短信</a>--> &nbsp; <a href="javascript:del_user()" class="a_btn" style="color:red;">删除</a>
                    </div>
                    
                    
                    <style>
                    .a_btn{
						border:1px solid #dcdfe6;
						padding:5px 8px;
						font-size:10px;
						border-radius:3px;
						}
						.a_right{
						font-size:1.1em;
						padding:7px 10px; 
						
						}
                    .pagination {
						margin:0px;
						}
                    </style>
                    
            		<?php if (isset($page))echo $page;?>
            	</div>
            </div>
		</div><!-- /.row -->
	</div><!-- /.page-content -->

	<script>

	document.onkeydown=function(event){                //网页内按下回车触发
		if(event.keyCode==13)
		{
			$('#export').val(0);
			$('#list_form').submit();                    
		}
	}
	
	$("select").change(function(){
	  $('#export').val(0);$('#list_form').submit();
	});
	function edit_user(){
		var uid_dom=$('.ids:checked');
			if(uid_dom.length==0){
				 	alert('请选择用户');
					return false;
			}
			var uid=$(uid_dom[0]).val();
			var dialog=art.dialog({
				id: 'edit_user',
				top:'50%'
			})
			$.ajax({
			   type: "POST",
			   url: "<?php echo base_url().'crm/user/edit_user'?>",
			   data: "id="+uid,
			   success: function(msg){
				 dialog.content(msg);
			   }
			});
			
			
	}
	
	function save_user(){
		var id=$('input[name="id"]').val();
		
		$.ajax({
			   type: "POST",
			   url: "<?php echo base_url().'crm/user/do_save_user'?>",
			   data: $("#edit_form").serialize(),
			   success: function(msg){
				  window.location.reload();
			   }
			});
	}
	function del_user(){
		var uid_dom=$('.ids:checked');
			if(uid_dom.length==0){
				 	alert('请选择用户');
					return false;
			}
			var ids=new Array();
			
			$('.ids:checked').each(function(index, element) {
                ids.push($(this).val());
            });
			
			if(confirm('是否删除用户')){
				$.ajax({
					   type: "POST",
					   url: "<?php echo base_url().'crm/user/del_user'?>",
					   data: {'ids':ids},
					   success: function(msg){
						 window.location.reload();
					   }
					});
				
			}
		
		
	}
	function close_edit(){
		
		art.dialog({id:'edit_user'}).close();
	}
	function remove_user(){
		var uid_dom=$('.ids:checked');
			if(uid_dom.length==0){
				 	alert('请选择用户');
					return false;
			}
			var ids=new Array();
			
			$('.ids:checked').each(function(index, element) {
                ids.push($(this).val());
            });
			
			var dialog=art.dialog({
				id: 'remove_user',
				top:'50%',
				ok:function(){
					var server_id=$('#server_id').val();
					$.ajax({
					   type: "POST",
					   url: "<?php echo base_url().'crm/user/do_remove_user'?>",
					   data: {'ids':ids,'server_id':server_id},
					   success: function(msg){
						 window.location.reload();
					   }
					});
					},
				cancel:function(){}	
			})
			$.ajax({
			   type: "POST",
			   url: "<?php echo base_url().'crm/user/remove_user'?>",
			   
			   success: function(msg){
				 dialog.content(msg);
			   }
			});
		
	}
	
	function send_msg(){
		var has_send=0;
		var uid_dom=$('.ids:checked');
		if(uid_dom.length==0){
				alert('请选择用户');
				return false;
		}
		var ids=new Array();
		
		$('.ids:checked').each(function(index, element) {
			ids.push($(this).val());
		});
		
		var dialog=art.dialog({
			id: 'remove_user',
			top:'50%',
			
			ok:function(){
				if(has_send==1){
					alert('正在发送中请稍候...');
					return false;
				}
				var msg_text=$('#msg_text').val();
				$('.aui_state_highlight').text('发送中...')
				has_send=1;
				
				$.ajax({
				   type: "POST",
				   url: "<?php echo base_url().'crm/user/do_send_msg'?>",
				   data: {'ids':ids,'msg_text':msg_text},
				   success: function(msg){
					 
				   }
				});
				},
			cancel:function(){}	
		})
		$.ajax({
		   type: "POST",
		   url: "<?php echo base_url().'crm/user/send_msg'?>",
		   
		   success: function(msg){
			 dialog.content(msg);
		   }
		});
		
		
	}
		
	
	
	
	$('#select_all').click(function(){
			
			$('.ids').prop('checked',$(this).prop('checked'))
			$('#select_num').text($('.ids:checked').length);
	})
	
	$('.ids').click(function(){	
			$('#select_num').text($('.ids:checked').length);
	})
	
    function follow(aid){
		
		var dialog=art.dialog({
			id: 'msg',
			top:'55%',
			left:'71%',
			fixed:true
		})
		
		$.ajax({
		   type: "POST",
		   url: "<?php echo base_url().'crm/user/follow_info'?>",
		   data: "id="+aid,
		   success: function(msg){
			 dialog.content(msg);
		   }
		});
		
		
		}
     $(function () {
        $('#follow_start').datetimepicker({
            format: 'yyyy-mm-dd hh:ii',
			autoclose: true,
			minView: 0,
			language:'zh-CN'
        });
        $('#follow_end').datetimepicker({
            format: 'yyyy-mm-dd hh:ii',
			autoclose: true,
			minView: 0,
			language:'zh-CN'
        });
		
		$('#reg_start').datetimepicker({
              minView: "month",//设置只显示到月份
			  format : "yyyy-mm-dd",//日期格式
			  autoclose:true,//选中关闭
			  language:'zh-CN'
        });
        $('#reg_end').datetimepicker({
            minView: "month",//设置只显示到月份
			  format : "yyyy-mm-dd",//日期格式
			  autoclose:true,//选中关闭
			  language:'zh-CN'
        });
    });
    </script>